# AT91Boostrap: Arietta G25
# Maintainer: Kevin Mihelich <kevin@archlinuxarm.org>

buildarch=2

pkgbase=at91bootstrap-arietta
pkgname=("${pkgbase}-128" "${pkgbase}-256")
pkgver=v3.7.r25.g3f957ce
pkgrel=1
arch=('arm')
url="https://github.com/tanzilli/at91bootstrap"
makedepends=('git' 'bc')
license=('GPL')
source=("git+https://github.com/tanzilli/at91bootstrap.git"
        '0001-arietta-dtb-name-fix.patch'
        '0002-fix-for-gcc-5.patch')
md5sums=('SKIP'
         '48707263a58bfaf566641bbcf080fdea'
         'b6e82a87eda88cc63f1df3965e9e544f')

pkgver() {
  cd at91bootstrap
  ( set -o pipefail
    git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
  )
}

prepare() {
  cd at91bootstrap

  git apply ../0001-arietta-dtb-name-fix.patch
  git apply ../0002-fix-for-gcc-5.patch
}

build() {
  cd at91bootstrap

  unset LDFLAGS CFLAGS CXXFLAGS

  make mrproper
  make arietta-128m_defconfig
  make
  cp binaries/at91sam9x5_arietta-sdcardboot-linux-zimage-dt-3.7.bin boot128.bin

  make clean
  make arietta-256m_defconfig
  make
  cp binaries/at91sam9x5_arietta-sdcardboot-linux-zimage-dt-3.7.bin boot256.bin
}

package_at91bootstrap-arietta-128() {
  pkgdesc="AT91Boostrap for Arietta G25 128MB"

  mkdir -p "${pkgdir}"/boot
  cp at91bootstrap/boot128.bin "${pkgdir}"/boot/boot.bin
}

package_at91bootstrap-arietta-256() {
  pkgdesc="AT91Boostrap for Arietta G25 256MB"

  mkdir -p "${pkgdir}"/boot
  cp at91bootstrap/boot256.bin "${pkgdir}"/boot/boot.bin
}
